#ifndef MAINALGO_H
#define MAINALGO_H

#include <QMainWindow>
#include <QFileDialog>
#include <QMessageBox>
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <QPointF>
#include <QVector>
#include <iostream>
#include <QMap>
#include <QDateTime>

#define A 1
#define B 2
#define C 3
#define D 4
#define E 5
#define F 6
#define G 7
#define H 8
#define I 9
#define J 10
#define K 11
#define L 12
#define M 13
#define N 14
#define O 15
#define P 16

namespace Ui {
    class MainAlgo;
}

struct Pion{
    //Pion(int num_,char nord_) : num(num_), nord(nord_){}
    int num;
    char nord;
};

struct PionPos{
    Pion piece;
    int x;
    int y;
};

struct PairePionPos{
    Pion pion1;
    Pion pion2;
};

class MainAlgo : public QMainWindow
{
    Q_OBJECT

/* ATTRIBUT PRIVATE */
private:
    Ui::MainAlgo *ui;
    QString fichier;
    QString name;
    QString type;
    QString patchSortieJeton;
    QString comment;
    int dimension;
    QString display_data;
    QVector<QVector<Pion> > solution;
    QVector<QVector<char> > Pieces;
    int tailleMax;
    QString patchJeton;
    QMap<char,int> correspondanceCI;
    QMap<int,char> correspondanceIC;
    QVector<int> bonneSolution;
    QVector<int> listTabouR;
    QVector<PairePionPos> listTabou;
    bool useListTabou;
    int tailleListeTabou;

    bool stopAlgo;

/* METHODE PUBLIC */
public:
    explicit MainAlgo(QWidget *parent = 0);
    float tailleTotal(QVector<int> sol);
    void initFile();
    void init();
    ~MainAlgo();

/* METHODE PRIVATE */
private:
    int checker(QVector<QVector<Pion> > &sol);
    int accesCase (QVector<PionPos> plateau, int val1 , int val2);
    char pole(int num,char ori,char p);
    void vvpToVvpp(QVector<QVector<Pion> > &in,QVector<QVector<PionPos> > &out);
    void BonChangement(QVector<QVector<Pion> > &in,int t,int nb);
    void Permute(QVector<PionPos> &pion);
    void rotate(QVector<PionPos> &pion);
    int nbdeZ(QVector<char> z);
    int searchLastZ(QVector<char> z);
    void BonOrientation(PionPos &pp);
    void initialisationSolution();
    float heur(int un,int deux);
    void vvppToVvp(QVector<QVector<PionPos> > &in,QVector<QVector<Pion> > &out);

/* SLOTS PRIVATE */
private slots:
    void on_check_clicked();
    void on_sortie_clicked();


    void on_algo_clicked();
    void on_stop_clicked();
    void on_tabou_clicked();
    void on_descente_clicked();
};

#endif // MAINALGO_H
